package com.mc.servlet;
import com.mc.service.MatchService;
import com.mc.service.impl.MatchServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author zl
 * 赛事删除控制器
 */
@WebServlet("/deletematch.action")
public class DeleteMatchServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取业务逻辑控制器
        MatchService matchService = new MatchServiceImpl();

        //接收用户传入的id
        String id = req.getParameter("id");


        int mid = Integer.parseInt(id);
        System.out.println(id);
        boolean flag = matchService.delete(mid);

        System.out.println(flag);

        resp.sendRedirect("matchlist.action");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
